package com.feihao.zhou.servlet;

import com.feihao.zhou.domain.Student;
import com.feihao.zhou.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@WebServlet("/findOneStudentServlet")
public class FindOneStudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取前端请求数据：
        String sid = req.getParameter("id");
        //根据sid返回一个student对象：
        StudentService studentService = new StudentService();
        Student student = studentService.findStudentById(sid);

        //将student对象转发到 deleteStudent.jsp
        req.setAttribute("Student", student);

        req.getRequestDispatcher("/updateStudent.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
